<?php
/**
 * @brief change_stat protocol
 *
 * @param post uid User ID
 * @param post stat_a User Atk_Stat
 * @param post stat_b User Hit_Stat
 * @param post stat_c User Def_Stat
 * @param post stat_d User Spd_Stat
 * @return True/False
 * @author con100 <con100@playplus.net>
 * @since 11/04/2013
 * @copyright Copyright (c) 2013, PlayPlus
 **/

include 'dbconn.php';
include 'config.php';

$user_id = mysql_real_escape_string($_POST['uid']);
$stat_a = mysql_real_escape_string($_POST['stat_a']);
$stat_b = mysql_real_escape_string($_POST['stat_b']);
$stat_c = mysql_real_escape_string($_POST['stat_c']);
$stat_d = mysql_real_escape_string($_POST['stat_d']);

$sql = "select level from ebs_member where id='$user_id'";
$res = mysql_query($sql);
$data = mysql_fetch_assoc($res);

$check = $data['level'] * $stat_levelup;
$sum = $stat_a + $stat_b + $stat_c + $stat_d;
if($check >= $sum){
	$sql = "update ebs_member set sp_atk='$stat_a', sp_hit='$stat_b', sp_def='$stat_c', sp_spd='$stat_d' where id='$user_id'";
	$res = mysql_query($sql);
	$result = array("Result"=>TRUE);
}else{
	$result = array("Result"=>FALSE);
}
echo json_encode($result);
/*
header('Content-type: text/xml; charset=UTF-8');

$writer = new XMLWriter();
$writer->openMemory();
$writer->setIndent(true);
$writer->setIndentString('  ');
$writer->startDocument('1.0', 'UTF-8');

$writer->startElement('change_stat');
	$writer->startElement('result');
	$writer->text($result);
	$writer->endElement();
$writer->endElement();

echo($writer->outputMemory());
*/
?>